<template>
    <div class="newsinfo-container">
        <h1 class="tittle">{{newsinfo.tittle}}</h1>
        <p class="subtittle">
        <span>发表时间：{{newsinfo.add_time|dateFormat}}</span>
        <span>点击：{{newsinfo.click}}0次</span>
        </p>
        <hr>
        <!--内容区域 -->
        <div class="content" v-html="newsinfo.content">
      {{newsinfo.content}}
        </div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
    import comment from '../subcomponents/comment.vue'
    import {Toast} from 'mint-ui'
    export default {
        name: "NewsInfo",
        data(){
            return{
                id:this.$route.params.id,
                newsinfo:[]
            }
        },
        created(){
            this.getNewsInfo()
        },
        methods:{
            getNewsInfo(){
                this.$http.get('Java/newsinfo' + this.id+".json/").then(result=>{
                    if (result.body.status === 0){
                        this.newsinfo = result.body.message[0]
                    }
                    else {
                        Toast('获取新闻资讯失败')
                    }
                })
            }
        },
        components:{
            "comment-box":comment
        }
    }
</script>

<style lang="scss" scoped>
  .newsinfo-container{
      padding: 0 4px;
      .tittle{font-size: 16px;text-align: center;margin: 0 15px;color: red }
      .subtittle{font-size: 13px;color: #226aff;display: flex;justify-content: space-between }
      .content{ }
  }
</style>